import React, { useState, useEffect } from 'react'

const LikeButton: React.FC = () => {
  const [obj, setObj] = useState({ like: 0, on: true })
  const [on, setOn] = useState(true)
  useEffect(()=>{
    document.title = `点击了${obj.like}次`
  },[obj.like])
  return (
    <>
      <button onClick={() => { setObj({ like: obj.like + 1, on: obj.on }) }}>
        {obj.like}1
      </button>
      <button onClick={() => setOn(!on)}>
        {on ? 'ON' : 'OFF'}
      </button>
    </>
  )
}

export default LikeButton